FROM node:18-alpine as build

WORKDIR /app

COPY package*.json ./

RUN npm install

COPY . .

RUN npm run build

# Using nginx to serve the frontend
FROM nginx:alpine

# Copy the build output to nginx
# Adjust this path based on your actual build output directory
# It might be 'dist', 'build', or something else depending on your frontend framework
COPY --from=build /app/dist /usr/share/nginx/html
# If you're using Create React App, it would be:
# COPY --from=build /app/build /usr/share/nginx/html

# Copy nginx configuration
COPY nginx.conf /etc/nginx/conf.d/default.conf

EXPOSE 8888

CMD ["nginx", "-g", "daemon off;"]